<template>
  <div class="page-miH page-bgBack">
    <a-row type="flex" class="setHead">
      <a-icon type="left" style="font-size: 16px; cursor: pointer" @click="goback" />
      <div>{{ componentTit[current] }}</div>
      <div></div>
    </a-row>
    <div class="tabbox">
      <div class="setting-stepbox">
        <a-steps :current="current" @change="stepsChange">
          <a-step title="签署设置" />
          <a-step title="合同模板" />
        </a-steps>
      </div>
    </div>
    <signed v-if="current == 0" ref="signed" @upData="upData" />
    <temp v-if="current == 1" @upData="upData" />
  </div>
</template>
<script>
import signed from "./signed";
import temp from "./temp";
export default {
  components: {
    signed,
    temp
  },
  data() {
    return {
      current: 0,
      componentTit: ["新增合同模板", "编辑合同模板"]
    };
  },
  watch: {
    current(v) {
      sessionStorage.setItem("editSealNewStatus", v);
    }
  },
  mounted() {
    const editSealNewStatus = sessionStorage.getItem("editSealNewStatus");
    this.current = editSealNewStatus ? parseInt(editSealNewStatus) : 0;
  },
  methods: {
    goback() {
      this.$confirm({
        title: "合同设置尚未保存，是否确认离开？",
        okText: "确定",
        cancelText: "取消",
        onOk: () => {
          this.$router.go(-1);
        }
      });
    },
    upData(e) {
      this.current = e;
    },
    stepsChange(e) {
      if (e === 1) {
        this.$refs.signed.saveSign();
        return false;
      }
      this.current = e;
    }
  }
};
</script>
<style lang="scss" scoped>
.setHead {
  // position: sticky;
  // top: 0;
  background: #fff;
  width: 100%;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e8e8e8;
  padding: 0 24px;
  z-index: 99;
  div {
    font-size: 16px;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.85);
  }
}
.tabbox {
  padding: 12px 24px;
  background: #fff;
  .setting-stepbox {
    // overflow: auto;
    .ant-steps {
      height: 88px;
      display: flex;
      align-items: center;
      background: #fff;
      box-shadow: 0px 4px 12px 0px rgba(106, 102, 246, 0.1) !important;
      border-radius: 4px;
      padding: 0 350px;
    }
  }
}
.btnlines {
  width: 100%;
  height: 64px;
  border-top: 1px solid #e8e8e8;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  position: fixed;
  right: 0px;
  bottom: 0px;
  background: #fff;
  padding-right: 28px;
}
</style>
